import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-03-21
 * Time: 19:30
 */
public class Demo1 {
    //递归求 N 的阶乘
    public static void main(String[] args) {
        Scanner scan = new Scanner( System.in );
        int n = scan.nextInt();
        System.out.println(fact(n));
    }
    public static int fact(int n) {
        if( n==1 ) {
            return n;
        } else {
            return n*fact(n-1);
        }
    }
    //递归求 1 + 2 + 3 + ... + 10
    public static void main5(String[] args) {
        System.out.println(Sum(10));
    }
    public static int Sum (int n) {
        if(n==0) {
            return n;
        } else {
            return n+ Sum(n-1);
        }
    }
    //递归打印数字的每一位
    public static void main6(String[] args) {
        int n=12345;
        System.out.println(prin(n));
    }
    public static int prin(int n) {
        if( n<10 ) {
            return n;
        } else {
            System.out.println(n%10);
            return prin(n/10);
        }
    }
    //写一个递归方法，输入一个非负整数，返回组成它的数字之和
    public static void main3(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        System.out.println(sum(n));
    }
    public static int sum (int n) {
        int s=0;
        if( n < 10 ) {
            return n;
        } else {
            return n%10 + sum(n/10);
        }
    }
    //2.递归求斐波那契数列的第 N 项
    public static void main2(String[] args) {
        int n = 0;
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        System.out.println(Fibonacci(n));
    }
    public static int Fibonacci(int n) {
        if( n<= 2 ) {
            return 1;
        } else {
            return (Fibonacci(n-1) + Fibonacci(n-2));
        }
    }
    //求最大值方法的重载
    /*在同一个类中定义多个方法：
    要求不仅可以求两个整数的最大值，
    还可以求两个小数的最大值，
    以及两个小数和一个整数的大小关系
     */
    public static void main1(String[] args) {
        int a=10;
        int b= 10;
        double c= 15.5;
        double d =1.5;
        int ret1 = max(a,b);
        System.out.println(ret1);
        int ret2 = max(c,d);
        System.out.println(ret2);
        int ret3 = max(b,c,d);
        System.out.println(ret3);

    }
    public static int max(int a, int b) {
        return (a>b?a:b);
    }
    public static int max(double a,double b) {
        return (int)(a>b?a:b);
    }
    public static int max(int a,double b,double c) {
        if( a>b ) {
            if( b>c ) {
                return a;
            } else if( b<c) {
                if( a>c ) {
                    return a;
                } else {
                    return (int)c;
                }
            }
        } else {
            if( a>c ) {
                return (int)b;
            } else if( c>a) {
                if( c>b ) {
                    return (int)c;
                } else {
                    return (int)b;
                }
            }
        }
        return -1;
    }

}
